package com.ecfront.test.dao;

import java.util.Date;
import java.util.Iterator;
import java.util.List;

import com.ecfront.dao.NoteDAO;
import com.ecfront.pojo.Admin;
import com.ecfront.pojo.Note;

import junit.framework.TestCase;

public class testNote extends TestCase {
	private static final NoteDAO noteDao = (NoteDAO)SpringUtilTest.getBean("NoteDAO");
	//save or update test
	public void testSaveOrUpdate(){
		Note note = new Note();
		//note.setId(1);
		note.setContent("本站成立了！！欢迎大家赏脸！");
		note.setDate(new Date());
		note.setTitile("热烈庆祝-修改");
		
		Admin admin = new Admin();
		admin.setAdminId(1);
		note.setAdminId(admin);
		
		noteDao.save(note);
	}
	//findall test
	public void testFindAll(){
		List list = noteDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			Note note = (Note)iter.next();
			System.out.println(note.getTitile());
			System.out.println(note.getAdminId().getAdminName());
		}
	}
	//findById test
	public void testFindById(){
		Note note = noteDao.findById(1);
		System.out.println(note.getTitile());
		System.out.println(note.getAdminId().getAdminName());
	}
	//delete test
	public void testDel(){
		Note note = new Note();
		note.setId(2);
		
		noteDao.delete(note);
	}
	//property test
	public void testProperty(){
		List list = noteDao.findByNtitle("热烈庆祝-修改");
		for(Iterator iter = list.iterator();iter.hasNext();){
			Note note = (Note)iter.next();
			System.out.println(note.getTitile());
			System.out.println(note.getAdminId().getAdminName());
		}
	}
}
